function checkRegister(){
    if(document.getElementById('register_user_username').value == ''){
        alert('请输入登陆用户名！');
        return false;
    }
    if(!checkEmail(document.getElementById('register_user_email').value)){
        alert("请输入合法的邮箱帐号");
        return false;
    }
    if(document.getElementById('register_user_password').value == ''){
        alert('密码不能为空！');
        return false;
    }
    if(document.getElementById('register_confirm_password').value == ''){
        alert('确认密码不能为空！');
        return false;
    }
    if(document.getElementById('register_user_password').value
            != document.getElementById('register_confirm_password').value){
        alert('两次输入密码不一致！');
        return false;
    }
    if(document.getElementById('register_user_name').value == ''){
        alert('请输入姓名！');
        return false;
    }
    if(document.getElementById('register_user_age').value == ''){
        alert('请输入年龄！');
        return false;
    }
    if(document.getElementById('register_user_sex').value == -1){
        alert('请选择性别！');
        return false;
    }
    if(document.getElementById('register_user_degree').value == -1){
        alert('请选择学历！');
        return false;
    }
    if(document.getElementById('register_user_major').value == -1){
        alert('请选择专业！');
        return false;
    }
    if(document.getElementById('register_user_grade').value == -1){
        alert('请选择年级！');
        return false;
    }
    if(document.getElementById('register_user_source').value == -1){
        alert('请选择生源地！');
        return false;
    }
    if(document.getElementById('register_schoolId').value == -1){
        alert('请选择高校！');
        return false;
    }
    if(document.getElementById('register_user_studentId').value == ''){
        alert('请输入学号！');
        return false;
    }
    if(document.getElementById('register_user_email').value == ''){
        alert('请输入登录邮箱！');
        return false;
    }
}

function checkEmail(obj) {
   // var exp= /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;//验证Mail的正则表达式,^[a-zA-Z0-9_-]:开头必须为字母,下划线,数字,
    var exp= /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/
    var reg = obj.match(exp); 
    if(reg==null)
        return false; 
    return true; 
} 

function checkOption(){
	var k = 0;
	var itemValue = document.getElementsByName('questionValue');
	var page = document.getElementById('questionForm_page');
	for (var item = 0; item < 10; item++){
		var array= document.getElementsByName('qItem['+item+']');
		if(array && array.length > 0){
			var isChecked = false;
			for(i = 0; i < array.length; i++){
				if(array[i].checked){
					isChecked = true;
					itemValue[k++].value = array[i].value;
				}
			}
			if(!isChecked){
				alert('第' + ((page.value - 1) * 10 + item + 1) + '题未作答！');
				return false;
			}
		}
	}
	return true;
}
function lastQuestion(){
	   var doc = document.getElementById("questionForm");
	   doc.action = 'lastQuestion.htm';
	   doc.target = '_self';
	   doc.submit();
}

function checkUpdate(){
    var password = document.getElementById('accountsUpdate_newPassword').value
    var pwagain = document.getElementById('accountsUpdate_againPassword').value
    if(password == null || password == ''){
        alert("请输入登录密码");
        return false;
    }
    if(password != pwagain){
        alert("两次密码输入不一致");
        return false;
    }
    return true;
}
function checkfrm(){
    var username = document.getElementById('accountsAdd_user_username').value
    var password = document.getElementById('accountsAdd_user_password').value
    var pwagain = document.getElementById('accountsAdd_passwordAgain').value
    var school = document.getElementById('accountsAdd_schoolId').value
    if(username == null || username == ''){
        alert("请输入登录帐号");
        return false;
    }
    if(password == null || password == ''){
        alert("请输入登录密码");
        return false;
    }
    if(password != pwagain){
        alert("两次密码输入不一致");
        return false;
    }
    if(school == -1 || school == '-1'){
        alert('请选择高校');
        return false;
    }
    return true;
}

function checkIPAddr(obj) {
    var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/; 
    var reg = obj.match(exp); 
    if(reg==null)
        return false; 
    return true; 
} 

function ipQuery(){
	var v = document.getElementById('ipManager_name').value
    if(v != null && v != ''){
        if(!checkIPAddr(v)){
            alert("请输入合法的IP地址");
            return false;
        }
    }
    return true;
}
function fromChange(ip){
	document.getElementById('ipAdd_ip_endIP').value = ip;
}
function checkIPfrm(){
    var ip1 = document.getElementById('ipAdd_ip_fromIP').value
    var ip2 = document.getElementById('ipAdd_ip_endIP').value
    var school = document.getElementById('ipAdd_addSchoolId').value
    if(ip2 == null || ip2 == '' || ip1 == null || ip1 == ''){
        alert("请输入IP地址");
        return false;
    }
    if(!checkIPAddr(ip1)){
        alert("请输入合法的起始IP地址");
        return false;
    }
    if(!checkIPAddr(ip2)){
        alert("请输入合法的结束IP地址");
        return false;
    }
    if(school == -1 || school == '-1'){
        alert('请选择高校');
        return false;
    }
    return true;
}
function checkExpertConsult(){
	var doc = document.getElementById('userExpertConsult');
	if(doc.exportUserId[0].checked == false && doc.exportUserId[1].checked == false){
		alert('请选择一位专家');
		return false;
	}
	if(doc.userTel.value == null || doc.userTel.value == ''){
		alert('请输入您的联系电话');
		return false;
	}
	return true;
}
function disSchoolReport(sid){
	   var doc = document.getElementById("accountsUpdate");
	   doc.action = 'admin/disSchoolReport.htm?id='+sid;
	   doc.target = '_self';
	   doc.submit();
}

function exportData(){
	var doc = document.getElementById("userManager");
	doc.action = 'admin/exportDate.htm';
    doc.target = '_self';
    doc.submit();	
}
function generateData(){
	var doc = document.getElementById("userManager");
	doc.action = 'generateDate.htm';
    doc.target = '_self';
    doc.submit();	
}

function addSchool(){
	var doc = document.getElementById('schoolAdd');
	if(doc.schoolName.value == null || doc.schoolName.value == ''){
		alert("请输入院系名称");
		return false;
	}
	if(doc.schoolType.value == -1){
		alert("请选择院系类型");
		return false;
	}
	if(doc.schoolType.value == 20 && (doc.id.value == null || doc.id.value == '')){
		alert("请选择所属高校");
		return false;
	}
	return true;
}
function isChoseGaoXiao(){
	var doc = document.getElementById('schoolManager');
	return false;
}
function checkChose(obj){
	var doc = document.getElementById('schoolManager');
	if(obj.checked == true){
		document.getElementById('schoolAdd').id.value = obj.value;
		if(doc.chk_school.length){
			for(i = 0; i < doc.chk_school.length; i++){
				if(doc.chk_school[i].checked == true && doc.chk_school[i].value != obj.value){
					doc.chk_school[i].checked = false;
				}
			}
		}
	}
	else
		document.getElementById('schoolAdd').id.value = '';
}
function checkResetPwd(){
	var doc = document.getElementById('resetPwd');
	if(doc.email.value == null || doc.email.value == ''){
		alert('请输入您的注册邮箱');
		return false;
	}
	return true;
}
function checkUpdatePwd(){
	var doc = document.getElementById('resetPwdCommit');
	if(doc.password.value == null || doc.password.value == ''){
		alert('请输入您的新密码');
		return false;
	}
	if(doc.password.value != doc.password2.value){
		alert('两次输入的密码不一致');
		return false;
	}
	return true;
}
function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
